package src.Packets;

import src.Main;
import src.Players.*;

public class ItemSelect
{
    private int prayerXPRate = 1;
    public ItemSelect(Player p)
    {
        if(p == null || p.inStream == null)
        {
            return;
        }
        int interfaceId = p.inStream.readSignedWordBigEndianA();
        int itemSlot = p.inStream.readUnsignedWordA();
        int itemId = p.inStream.readUnsignedWordBigEndian();
        PlayerItems pi = new PlayerItems();
        if(pi.invItemCount(p, itemId) < 1)
        {
            return;
        }
        if(p.isDead || p.skillLvl[3] < 1)
        {
            return;
        }
        if(interfaceId == 3214)
        {
            p.attackingPlayer = false;
            p.attackingNPC = false;
            p.attackNPC = 0;
            p.attackPlayer = 0;
            switch(itemId)
            {
                case 391:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(22, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 385:
                case 397:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(20, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 315:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(3, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 319:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(1, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 325:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(4, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 329:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(9, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 339:
                case 333:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(7, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 347:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(5, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 351:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(8, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 355:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(6, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 361:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(10, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 365:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(13, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 7946:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(16, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 379:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(12, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 373:
                    if(p.eatDelay <= 0)
                    {
                        p.eatDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.updateHP(16, true);
                        p.requestAnim(829, 0);
                    }
                break;
                case 3024:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.26) + 8, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.26) + 8, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.26) + 8, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.26) + 8, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.26) + 8, 0, true);
                        changeStat(p, 5, (int)(p.getLevelForXP(5) * 0.26) + 8, 0, true);
                        pi.addItem(p, 3026, 1);
                    }
                break;
                case 3026:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.26) + 8, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.26) + 8, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.26) + 8, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.26) + 8, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.26) + 8, 0, true);
                        changeStat(p, 5, (int)(p.getLevelForXP(5) * 0.26) + 8, 0, true);
                        pi.addItem(p, 3028, 1);
                    }
                break;
                case 3028:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.26) + 8, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.26) + 8, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.26) + 8, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.26) + 8, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.26) + 8, 0, true);
                        changeStat(p, 5, (int)(p.getLevelForXP(5) * 0.26) + 8, 0, true);
                        pi.addItem(p, 3030, 1);
                    }
                break;
                case 3030:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.26) + 8, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.26) + 8, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.26) + 8, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.26) + 8, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.26) + 8, 0, true);
                        changeStat(p, 5, (int)(p.getLevelForXP(5) * 0.26) + 8, 0, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2430:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.3) + 10, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.3) + 10, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.3) + 10, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.3) + 10, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.3) + 10, 0, true);
                        pi.addItem(p, 127, 1);
                    }
                break;
                case 127:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.3) + 10, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.3) + 10, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.3) + 10, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.3) + 10, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.3) + 10, 0, true);
                        pi.addItem(p, 129, 1);
                    }
                break;
                case 129:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.3) + 10, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.3) + 10, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.3) + 10, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.3) + 10, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.3) + 10, 0, true);
                        pi.addItem(p, 131, 1);
                    }
                break;
                case 131:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.3) + 10, 0, true);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.3) + 10, 0, true);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.3) + 10, 0, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.3) + 10, 0, true);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.3) + 10, 0, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 6685:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        p.updateHP((int)(p.getLevelForXP(3) * 0.15) + 2, true);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 2, 0, false);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 2, 0, false);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.2) + 2, 1, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 2, 0, false);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.1) + 2, 0, false);
                        pi.addItem(p, 6687, 1);
                    }
                break;
                case 6687:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        p.updateHP((int)(p.getLevelForXP(3) * 0.15) + 2, true);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 2, 0, false);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 2, 0, false);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.2) + 2, 1, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 2, 0, false);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.1) + 2, 0, false);
                        pi.addItem(p, 6689, 1);
                    }
                break;
                case 6689:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        p.updateHP((int)(p.getLevelForXP(3) * 0.15) + 2, true);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 2, 0, false);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 2, 0, false);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.2) + 2, 1, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 2, 0, false);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.1) + 2, 0, false);
                        pi.addItem(p, 6691, 1);
                    }
                break;
                case 6691:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        p.updateHP((int)(p.getLevelForXP(3) * 0.15) + 2, true);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 2, 0, false);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 2, 0, false);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.2) + 2, 1, true);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 2, 0, false);
                        changeStat(p, 6, (int)(p.getLevelForXP(6) * 0.1) + 2, 0, false);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 113:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 3, 1, true);
                        pi.addItem(p, 115, 1);
                    }
                break;
                case 115:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 3, 1, true);
                        pi.addItem(p, 117, 1);
                    }
                break;
                case 119:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.1) + 3, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2432:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.1) + 3, 1, true);
                        pi.addItem(p, 115, 1);
                    }
                break;
                case 133:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.1) + 3, 1, true);
                        pi.addItem(p, 135, 1);
                    }
                break;
                case 135:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.1) + 3, 1, true);
                        pi.addItem(p, 137, 1);
                    }
                break;
                case 137:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.1) + 3, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2444:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 4, 1, true);
                        pi.addItem(p, 169, 1);
                    }
                break;
                case 169:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 4, 1, true);
                        pi.addItem(p, 171, 1);
                    }
                break;
                case 171:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 4, 1, true);
                        pi.addItem(p, 173, 1);
                    }
                break;
                case 173:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 4, (int)(p.getLevelForXP(4) * 0.1) + 4, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2428:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 3, 1, true);
                        pi.addItem(p, 121, 1);
                    }
                break;
                case 121:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 3, 1, true);
                        pi.addItem(p, 123, 1);
                    }
                break;
                case 123:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 3, 1, true);
                        pi.addItem(p, 125, 1);
                    }
                break;
                case 125:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.1) + 3, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2440:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.15) + 5, 1, true);
                        pi.addItem(p, 157, 1);
                    }
                break;
                case 157:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.15) + 5, 1, true);
                        pi.addItem(p, 159, 1);
                    }
                break;
                case 159:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.15) + 5, 1, true);
                        pi.addItem(p, 161, 1);
                    }
                break;
                case 161:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 2, (int)(p.getLevelForXP(2) * 0.15) + 5, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2442:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.15) + 5, 1, true);
                        pi.addItem(p, 163, 1);
                    }
                break;
                case 163:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.15) + 5, 1, true);
                        pi.addItem(p, 165, 1);
                    }
                break;
                case 165:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.15) + 5, 1, true);
                        pi.addItem(p, 167, 1);
                    }
                break;
                case 167:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 1, (int)(p.getLevelForXP(1) * 0.15) + 5, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 2436:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.15) + 5, 1, true);
                        pi.addItem(p, 145, 1);
                    }
                break;
                case 145:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.15) + 5, 1, true);
                        pi.addItem(p, 147, 1);
                    }
                break;
                case 147:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.15) + 5, 1, true);
                        pi.addItem(p, 149, 1);
                    }
                break;
                case 149:
                    if(p.drinkDelay <= 0)
                    {
                        p.drinkDelay = 3;
                        p.combatDelay += 2;
                        pi.deleteItem(p, itemId, itemSlot, 1);
                        p.requestAnim(829, 0);
                        changeStat(p, 0, (int)(p.getLevelForXP(0) * 0.15) + 5, 1, true);
                        pi.addItem(p, 229, 1);
                    }
                break;
                case 526:
                    p.requestAnim(827, 0);
                    p.addSkillXP(5 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
                case 532:
                    p.requestAnim(827, 0);
                    p.addSkillXP(15 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
                case 6729:
                    p.requestAnim(827, 0);
                    p.addSkillXP(125 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
                case 534:
                    p.requestAnim(827, 0);
                    p.addSkillXP(30 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
                case 530:
                    p.requestAnim(827, 0);
                    p.addSkillXP(6 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
                case 536:
                    p.requestAnim(827, 0);
                    p.addSkillXP(72 * prayerXPRate, 5);
                    pi.deleteItem(p, itemId, itemSlot, 1);
                break;
            }
        }
        pi = null;
    }

    public void changeStat(Player p, int stat, int amt, int type, boolean bol)
    {
        if(p == null)
        {
            return;
        }
        if(bol)
        {
            if(p.skillLvl[stat] >= (p.getLevelForXP(stat) + amt))
            {
                return;
            }
            p.skillLvl[stat] += amt;
            if(p.skillLvl[stat] >= (p.getLevelForXP(stat) + amt))
            {
                p.skillLvl[stat] = (p.getLevelForXP(stat) + amt);
            }
            if(type == 0)
            {
                if(p.skillLvl[stat] > p.getLevelForXP(stat))
                {
                    p.skillLvl[stat] = p.getLevelForXP(stat);
                }
            }
        }
        else if(!bol)
        {
            p.skillLvl[stat] -= amt;
            if(p.skillLvl[stat] < 1)
            {
                p.skillLvl[stat] = 1;
            }
        }
        p.frame.sendSkillLvl(p, stat);
    }
}